package com.bloody.android;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class PlayerMenu extends PlayerWindowInteraction implements View.OnClickListener{
	
	private Button resign;
	private Button pass;
	private Button back;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.player_menu);
        
        resign = (Button)findViewById(R.id.resign);
        resign.setOnClickListener(this);
        pass = (Button)findViewById(R.id.pass);
        pass.setOnClickListener(this);
        back = (Button)findViewById(R.id.back);
        back.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if (v == resign) {
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setMessage("Voulez-vous vraiment abandonner?")
			       .setCancelable(false)
			       .setPositiveButton("Oui", new DialogInterface.OnClickListener() {
			           public void onClick(DialogInterface dialog, int id) {
			        	   setResult(BloodyCrusadeGame.RES_RESIGN);
			   		       finish();
			           }
			       })
			       .setNegativeButton("Non", new DialogInterface.OnClickListener() {
			           public void onClick(DialogInterface dialog, int id) {
			                dialog.cancel();
			           }
			       });
			AlertDialog alert = builder.create();
			alert.show();
		}
		else if (v == pass) {
			setResult(BloodyCrusadeGame.RES_DONE);
			finish();
		}
		else if (v == back) {
			setResult(BloodyCrusadeGame.RES_BACK);
			finish();
		}
		
	}

}
